package com.zelin.listener;


import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;


/**
 * Created by WF on 2020/12/21 15:06
 */
@RunWith(SpringRunner.class)
@SpringBootTest
public class Producer01 {
    @Autowired
    private RabbitTemplate rabbitTemplate;

    //1.测试发送direct消息(直连模式)
    @Test
    public void test01(){
        rabbitTemplate.convertAndSend("zelin","hello，rabbitmq!");
    }

    //2.测试发送fanout消息(分裂模式)
    @Test
    public void test02(){
        rabbitTemplate.convertAndSend("zl-school","","正使用fanout模式发消息！");
    }

    //3.测试发送topic消息(主题模式)
    @Test
    public void test03(){
        rabbitTemplate.convertAndSend("threebooks","goods.aa","正在发送以goods开头的消息！");
    }

    //4.测试发送topic消息(主题模式)
    @Test
    public void test04(){
        rabbitTemplate.convertAndSend("threebooks","aa.log","正在发送以log结尾的消息！");
    }

    //5.测试发送topic消息(主题模式)
    @Test
    public void test05(){
        rabbitTemplate.convertAndSend("threebooks","goods.log","正在发送以goods开头和以log结尾的消息！");
    }
}
